using System;
using System.Collections;
using System.Collections.Generic;
using FrameWork;
using UnityEngine;
using Random = UnityEngine.Random;

public class Slime : MonoBehaviour
{
    [SerializeField] private GameObject coinsPrefab;

    public void Attack(float damage)
    {
        // 史莱姆死亡，随机生成奖品
        if (Random.Range(0, 100) < 60)
        {
            Instantiate(coinsPrefab, transform.position, Quaternion.identity);
        }
        
        // 通知史莱姆管理器生成新的史莱姆
        EventSystem.Instance.EventTrigger(EventName.EVENT_SLIME_SPAWN);
        
        // TODO:生成死亡粒子
        
        // 放回对象池
        ObjectPool.Instance.Replace("Slime", gameObject);
    }

    /// <summary>
    /// 碰撞玩家造成伤害
    /// </summary>
    /// <param name="other"></param>
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other != null && other.CompareTag("Player"))
        {
            //
        }
    }
}
